<?php
	class xl_nguoidung extends database
	{
		function LoadAll()
		{
			$sql = "Select * from nguoidung";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function Lay_email_theo_ten($ten)
		{
			$sql = "Select * from nguoidung where tendangnhap='".$ten."'";
			$this->setQuery($sql);
			$arr = $this->loadOneRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function kt_email($email)
		{
			$sql = "Select * from nguoidung where email='".$email."'";
			$this->setQuery($sql);
			$arr = $this->loadOneRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function kt_tendangnhap($ten)
		{
			$sql = "Select * from nguoidung where tendangnhap='".$ten."'";
			$this->setQuery($sql);
			$arr = $this->loadOneRow();
			$this->disconnect(); 
			return $arr;
			//return $sql;
		}
		
		function kt_matkhau($ma)
		{
			$sql = "Select * from nguoidung where matkhau='".$ma."'";
			$this->setQuery($sql);
			$arr = $this->loadOneRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function Load_nguoi_theo_ma($ma)
		{
			$sql = "Select * from nguoidung where manguoidung=".$ma;
			$this->setQuery($sql);
			$arr = $this->loadOneRow();
			$this->disconnect(); 
			return $arr;
		} 
		function capnhap($mauser,$hoten,$tendangnhap,$diachi,$dienthoai,$currentDate,$email)
		{
			$sql = "UPDATE nguoidung set tendangnhap='".$tendangnhap."', ngaytao ='".$currentDate."', email ='".$email."', hoten ='".$hoten."',diachi='".$diachi."',dienthoai='".$dienthoai."' where manguoidung=".$mauser;
			$this->setQuery($sql);
			return $this->query(); 
			//return $sql;
		}
		
		function capnhap1($mauser,$hoten,$tendangnhap,$matkhau,$diachi,$dienthoai,$currentDate,$email)
		{
			$sql = "UPDATE nguoidung set tendangnhap='".$tendangnhap."', matkhau ='".$matkhau."', ngaytao ='".$currentDate."', email ='".$email."', hoten ='".$hoten."',diachi='".$diachi."',dienthoai='".$dienthoai."' where manguoidung=".$mauser;
			$this->setQuery($sql);
			return $this->query(); 
			//return $sql;
		}
		
		function set_matkhau($matkhau,$tendangnhap)
		{
			$sql = "update nguoidung set matkhau='".$matkhau."' where tendangnhap='".$tendangnhap."'";
			$this->setQuery($sql);
			return $this->query();
			//return $sql;
		}
		
		function them($matkhau,$hoten,$tendangnhap,$diachi,$dienthoai,$currentDate,$email)
		{
			$sql = "INSERT INTO nguoidung (hoten,tendangnhap,matkhau, admin, diachi,dienthoai,ngaytao,email) VALUES ('".$hoten."','".$tendangnhap."','".$matkhau."', '0','".$diachi."','".$dienthoai."','".$currentDate."','".$email."')";
			$this->setQuery($sql);
			return $this->query();
			//return $sql;
			
		}
		function xoa_user($mauser)
		{
			$sql ="delete from nguoidung where manguoidung = '".$mauser."'";
			$this->setQuery($sql);
			return $this->query();
		}
	}
?>